<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<table id="i1" border="1" width="300px">
    <tr><td>1</td><td>2</td><td>2</td></tr>
    <tr><td>1</td><td>2</td><td>2</td></tr>
    <tr><td>1</td><td>2</td><td>2</td></tr>
</table>
<script>
        var myTrs = document.getElementsByTagName("tr");
        var len = myTrs.length;
        for(var i=0;i<len;i++) {
            myTrs[i].onmouseover = function () {
                this.style.backgroundColor = "red";
            };

            myTrs[i].onmouseout = function () {
                this.style.backgroundColor ="";
            }
        }
</script>
</body>
</html>